<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="redis" uri="http://www.shopjsp.com/redisTag/functions" %>
<c:set var="basePath" value="${redis:getSysConfig('base_path_back')}"/>
<script type="text/javascript">
    /**
     * 自定义验证规则
     */
    function validateForm(){
        form.bootstrapValidator({
            message: "无效的值",
            feedbackIcons: {
                valid: "glyphicon glyphicon-ok",
                invalid: "glyphicon glyphicon-remove",
                validating: "glyphicon glyphicon-refresh"
            },
            fields: {
                serverMessage: {
                    validators: {
                        notEmpty: {message: "客服留言不可为空"}
                    }
                }
            }
        });
    }

    /**
     * 审核金币提现申请
     */
    function editInfo() {
        /**获取选中行的id**/
        var selectedRow = $("#tt").bootstrapTable('getSelections');
        if (selectedRow.length == 1) {
            var id = selectedRow[0].detailId;
            $("#btn_edit").attr("data-target", "#addOrEditModal");/**选中了记录后才可打开对应的模态框**/
            $.ajax({
                type: "POST",
                dataType: "JSON",
                url: "${basePath}/back/shopMallCoinWithdrawals/getShopMallCoinWithdrawalsById.sjson",
                data: {detailId: id},
                success: function (result) {
                    var data = JSON.parse(result.data);
                    /**隐藏域**/
                    $("#detailId").val(data.detailId);
                    /**可见表单控件**/
                    var nowState;
                    if(data.state==1) nowState="申请提现";
                    if(data.state==2) nowState="审核通过";
                    if(data.state==3) nowState="审核未通过";
                    if(data.state==4) nowState="支付完成";
                    if(data.state==5) nowState="支付失败";
                    $("#nowState").html(nowState);
                    if(data.state==1){
                        $("#checktype1").attr("checked", true);
                        $("#checktype2").attr("checked", "none");
                        $("#checktype3").attr("checked", "none");
                    }else if(data.state==2){
                        $("#checktype1").attr("checked", "none");
                        $("#checktype2").attr("checked", true);
                        $("#checktype3").attr("checked", "none");
                    }else{
                        $("#checktype1").attr("checked", "none");
                        $("#checktype2").attr("checked", "none");
                        $("#checktype3").attr("checked", true);
                    }
                    $("#state_"+data.state).attr("checked",true); /**审核状态**/
                    $("#serverMessage").val(data.serverMessage);/**客服留言**/
                }
            });
        } else {
            $("#btn_edit").attr("data-target", "");/**没有选中记录不可打开模态框**/
            showMsg("请选择一行记录！");
        }
    }
</script>

<!--添加编辑模态框（Modal） -->
<div class="modal fade" id="addOrEditModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" >
	<div class="modal-dialog" style="width:70%">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h5 class="modal-title" id="myModalLabel">店铺金币提现审核</h5>
			</div>
			<div class="modal-body">
				<form id="form1"  method="post" action="${basePath}/back/shopMallCoinWithdrawals/saveOrUpdateShopMallCoinWithdrawalsObject.sjson">
					<input id="detailId" type="hidden" name="detailId" noclear="true"/>
					<table align="center" class="addOrEditTable table-bordered table" style="width:100%;">
						<tr>
							<td class="toright_td" width="150px">当前状态:&nbsp;&nbsp;</td>
							<td class="toleft_td" colspan="3">&nbsp;&nbsp;<span id="nowState"></span>&nbsp;&nbsp;&nbsp;</td>
						</tr>
						<tr>
							<td class="toright_td" width="150px"><span style="color:red">* </span>审核操作:&nbsp;&nbsp;</td>
							<td class="toleft_td" width="150px" id="checktype1">&nbsp;&nbsp;
								<input id="state_2" type="radio" name="state" value="2" checked="checked"/>审核通过&nbsp;&nbsp;&nbsp;
								<input id="state_3" type="radio" name="state" value="3"/>审核未通过&nbsp;&nbsp;&nbsp;</td>
							<td class="toleft_td" width="150px" id="checktype2">&nbsp;&nbsp;
								<input id="state_4" type="radio" name="state" value="4" checked="checked"/>支付完成&nbsp;&nbsp;&nbsp;
								<input id="state_5" type="radio" name="state" value="5"/>支付失败&nbsp;&nbsp;&nbsp;</td>
							<td class="toleft_td" width="150px" id="checktype3">&nbsp;&nbsp;不可操作&nbsp;&nbsp;&nbsp;</td>
						</tr>
						<tr>
							<td class="toright_td" width="150px"><span style="color:red">* </span>客服留言:&nbsp;&nbsp;</td>
							<td  class="toleft_td" colspan="3">
								<div class="form-group">
									<input type="text" class="form-control input-sm" id="serverMessage" name="serverMessage" placeholder="请输入客服留言"/>
								</div>
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" id="validateBtn" class="btn btn-primary"  onclick="submitForm()">保存</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
